package com.mjf.kxml.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * desc
 * </p>
 *
 * @author chenshoumeng
 * @date 2025/6/4 10:58
 */
@Getter
public enum CKApiEnum {

    /**
     * 天津消息号：合同 013244ERP000001
     *             客商 013244ERP000006
     * 上海消息号：合同 013263ERP000001
     *             客商 013263ERP000006
     */

    CK_API_MERCHANT("301", "司库数据采集客商接口", "http://esbqas.cccar.com.cn:7802/services/IF_Service", "013244ERP000006"),
    CK_API_CONTRACT("302", "司库数据采集合同接口", "http://esbqas.cccar.com.cn:7802/services/IF_Service", "013244ERP000001"),
    CK_API_RECEIVABLE("303", "司库数据采集应收增项接口", "http://esbqas.cccar.com.cn:7802/services/IF_Service", "013244ERP000003"),
    CK_API_PAYABLE("304", "司库数据采集应付增项接口", "http://esbqas.cccar.com.cn:7802/services/IF_Service", "013244ERP000002"),
    ;

    private static final Map<String, CKApiEnum> LOOKUP_MAP = new HashMap<>(4, 1);

    static {
        for (CKApiEnum cstEnum : CKApiEnum.values()) {
            LOOKUP_MAP.put(cstEnum.codes, cstEnum);
        }
    }

    CKApiEnum(String codes, String name, String url, String msgId) {
        this.codes = codes;
        this.name = name;
        this.url = url;
        this.msgId = msgId;
    }

    /**
     * -- GETTER --
     *
     * @return 枚举值
     */
    private String codes;
    private String name;
    private String url;
    private String msgId;


    /**
     * 根据枚举值获取枚举
     *
     * @param codes codes
     * @return 若枚举值存在，返回对应的枚举，否则返回 null
     */
    public static CKApiEnum formValue(String codes) {
        return LOOKUP_MAP.get(codes);
    }

    @Override
    public String toString() {
        return "CKApiEnum{" +
            "codes='" + codes + '\'' +
            ", name='" + name + '\'' +
            ", url='" + url + '\'' +
            ", msgId='" + msgId + '\'' +
            '}';
    }
}
